#ifndef MY_STR_H
#define MY_STR_H 1

#define cpymem(dst, src, n)   (((u_char *) memcpy(dst, src, n)) + (n))
#define tolower(c)      (u_char) ((c >= 'A' && c <= 'Z') ? (c | 0x20) : c)
#define toupper(c)      (u_char) ((c >= 'a' && c <= 'z') ? (c & ~0x20) : c)


void     strlow(u_char *dst, u_char *src, size_t n);
u_char * cpystrn(u_char *dst , u_char *src , size_t n);
u_char * pstrdup(pool_t *pool, u_char *src , size_t n);
uint8_t  my_strcasecmp(u_char *s1, u_char *s2);
uint8_t  my_strncasecmp(u_char *s1, u_char *s2, size_t n);
u_char * strnstr(u_char *s1, char *s2, size_t len);
u_char * strstrn(u_char *s1, char *s2, size_t n);
u_char * strcasestrn(u_char *s1, char *s2, size_t n);
u_char * strlcasestrn(u_char *s1, u_char *last, u_char *s2, size_t n);

int8_t   rstrncmp(u_char *s1, u_char *s2, size_t n);
int8_t   rstrncasecmp(u_char *s1, u_char *s2, size_t n);
int8_t   memn2cmp(u_char *s1, u_char *s2, size_t n1, size_t n2);
int8_t   dns_strcmp(u_char *s1, u_char *s2);

int32_t  my_atoi(u_char *line, size_t n);
int32_t  my_atofp(u_char *line, size_t n, size_t point);
ssize_t  my_atosz(u_char *line, size_t n);
off_t    my_atoof(u_char *line, size_t n);
time_t   my_atotm(u_char *line, size_t n);
int32_t  my_hextoi(u_char *line, size_t n);
u_char * my_hex_dump(u_char *dst, u_char *src, size_t len);

void     encode_base64(u_char *dst, u_char *src,size_t len);
int32_t  decode_base64(u_char *dst, u_char *src);
int32_t  decode_base64url(u_char *dst, u_char *src);

uint32_t utf8_decode(u_char **p, size_t n);
size_t   utf8_length(u_char *p, size_t n);
u_char * utf8_cpystrn(u_char *dst, u_char *src, size_t n, size_t len);

#endif //MY_STR_H
